package model;

import java.util.ArrayList;
import javax.swing.Icon;

/**
 *
 * @author Joachim
 */
public class AnimatedTile extends Tile{
    protected ArrayList<Icon> icons;
    protected int animationCount;
    protected boolean ai;

    /**
     * Creates a new Tile with a moving image
     * @param x The x position of the Tile
     * @param y The y position of the Tile
     * @param ai Whether or not this Tile is moved by an AI
     * @param icons The Icon to display
     */
    public AnimatedTile(int x, int y, boolean ai, ArrayList<Icon> icons) {
        super(x, y);
        this.icons = icons;
        this.ai = ai;
        animationCount = 0;
    }
    
    /**
     * Get the next Icon in the animation cycle
     * @return 
     */
    public Icon getNextIcon() {
        increaseAnimation();
        return icons.get(animationCount);
    }
    
    /**
     * Get the value of ai
     *
     * @return the value of ai
     */
    public boolean isAi() {
        return ai;
    }

    /**
     * Set the value of ai
     *
     * @param ai new value of ai
     */
    public void setAi(boolean ai) {
        this.ai = ai;
    }
    
    protected void increaseAnimation() {
        animationCount = (animationCount >= icons.size()-1)?0:animationCount+1;
    }
}
